﻿//​已知有Grandson类和main函数如下：
#include <iostream>

using namespace std;
class Father
{
	string fathername;
public:
	Father(string name1) :fathername(name1)
	{};
		 void printFatherName()
		{
			cout << fathername << endl;
		}
};
class Son1:virtual public Father
{
	string  son1name;
public:
	 Son1(string name1, string name2) :Father(name1)
	{
		 son1name = name2;
	 }
	 void printSonName()
	 {
		 Father::printFatherName();
		 cout << son1name << endl;
	}
};
class Son2:virtual public Father
{
	string son2name;
public:
	Son2(string name1, string name2) :Father(name1)
	{
		son2name = name2;
	}
	void printSonName()
	{
		Father::printFatherName();
		cout << son2name << endl;
	}
};
class Grandson :public Son1, public Son2 {
	string grandsonName;
public:
	Grandson(string name1, string name2, string name3, string name4) :
		Father(name1), Son1(name1, name2), Son2(name1, name3), grandsonName(name4) {}
	void printGrandsonName() {
		cout << grandsonName << endl;
	}
};

int main() {
	string n1, n2, n3, n4;
	cin >> n1 >> n2 >> n3 >> n4;
	Grandson gson(n1, n2, n3, n4);
	gson.printFatherName();
	cout << endl;
	gson.Son1::printSonName();
	cout << endl;
	gson.Son2::printSonName();
	cout << endl;
	gson.printGrandsonName();
	return 0;
}
